using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;

public class PlayVfxOnEnable:MonoBehaviour {
	VisualEffect effect;

	float timeAfterEnable;
	[SerializeField] float stopTime;

	private void Awake() {
		effect=GetComponent<VisualEffect>();
	}
	private void OnEnable() {
		effect.Play();
		timeAfterEnable=0;
	}
	private void Update() {
		timeAfterEnable+=Time.deltaTime;
		if(stopTime>0&&timeAfterEnable>stopTime){
			timeAfterEnable=float.MinValue;
			effect.Stop();
		}
	}
}
